package com.gateway.common.dto.route;


import java.net.URI;
import java.util.List;
import java.util.Map;

/**
 * @program: ahcloud-gateway
 * @description:
 * @author: YuKai Fan
 * @create: 2023/2/21 23:20
 **/
public class RouteDefinitionDTO {

    /**
     * 路由id
     */
    private String id;

    /**
     * appId
     */
    private String appId;

    /**
     * 应用名
     */
    private String appName;

    /**
     * 服务id
     */
    private String serviceId;

    /**
     * rpc类型
     */
    private String rpcType;

    /**
     * 上下文路径
     */
    private String contextPath;

    /**
     * 当前环境
     */
    private String env;

    /**
     * 断言
     */
    private List<PredicateDefinitionDTO> predicates;

    /**
     * 过滤器
     */
    private List<FilterDefinitionDTO> filters;

    /**
     * uri
     */
    private URI uri;

    /**
     * 元数据
     */
    private Map<String, Object> metadata;

    /**
     * 序号
     */
    private Integer order;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getAppName() {
        return appName;
    }

    public void setAppName(String appName) {
        this.appName = appName;
    }

    public String getServiceId() {
        return serviceId;
    }

    public void setServiceId(String serviceId) {
        this.serviceId = serviceId;
    }

    public String getRpcType() {
        return rpcType;
    }

    public void setRpcType(String rpcType) {
        this.rpcType = rpcType;
    }

    public String getContextPath() {
        return contextPath;
    }

    public void setContextPath(String contextPath) {
        this.contextPath = contextPath;
    }

    public String getEnv() {
        return env;
    }

    public void setEnv(String env) {
        this.env = env;
    }

    public List<PredicateDefinitionDTO> getPredicates() {
        return predicates;
    }

    public void setPredicates(List<PredicateDefinitionDTO> predicates) {
        this.predicates = predicates;
    }

    public List<FilterDefinitionDTO> getFilters() {
        return filters;
    }

    public void setFilters(List<FilterDefinitionDTO> filters) {
        this.filters = filters;
    }

    public URI getUri() {
        return uri;
    }

    public void setUri(URI uri) {
        this.uri = uri;
    }

    public Map<String, Object> getMetadata() {
        return metadata;
    }

    public void setMetadata(Map<String, Object> metadata) {
        this.metadata = metadata;
    }

    public Integer getOrder() {
        return order;
    }

    public void setOrder(Integer order) {
        this.order = order;
    }


    public static final class Builder {
        private String id;
        private String appId;
        private String appName;
        private String serviceId;
        private String rpcType;
        private String contextPath;
        private String env;
        private List<PredicateDefinitionDTO> predicates;
        private List<FilterDefinitionDTO> filters;
        private URI uri;
        private Map<String, Object> metadata;
        private Integer order;

        private Builder() {
        }

        public static Builder builder() {
            return new Builder();
        }

        public Builder id(String id) {
            this.id = id;
            return this;
        }

        public Builder appId(String appId) {
            this.appId = appId;
            return this;
        }

        public Builder appName(String appName) {
            this.appName = appName;
            return this;
        }

        public Builder serviceId(String serviceId) {
            this.serviceId = serviceId;
            return this;
        }

        public Builder rpcType(String rpcType) {
            this.rpcType = rpcType;
            return this;
        }

        public Builder contextPath(String contextPath) {
            this.contextPath = contextPath;
            return this;
        }

        public Builder env(String env) {
            this.env = env;
            return this;
        }

        public Builder predicates(List<PredicateDefinitionDTO> predicates) {
            this.predicates = predicates;
            return this;
        }

        public Builder filters(List<FilterDefinitionDTO> filters) {
            this.filters = filters;
            return this;
        }

        public Builder uri(URI uri) {
            this.uri = uri;
            return this;
        }

        public Builder metadata(Map<String, Object> metadata) {
            this.metadata = metadata;
            return this;
        }

        public Builder order(Integer order) {
            this.order = order;
            return this;
        }

        public RouteDefinitionDTO build() {
            RouteDefinitionDTO routeDefinitionDTO = new RouteDefinitionDTO();
            routeDefinitionDTO.setId(id);
            routeDefinitionDTO.setAppId(appId);
            routeDefinitionDTO.setAppName(appName);
            routeDefinitionDTO.setServiceId(serviceId);
            routeDefinitionDTO.setRpcType(rpcType);
            routeDefinitionDTO.setContextPath(contextPath);
            routeDefinitionDTO.setEnv(env);
            routeDefinitionDTO.setPredicates(predicates);
            routeDefinitionDTO.setFilters(filters);
            routeDefinitionDTO.setUri(uri);
            routeDefinitionDTO.setMetadata(metadata);
            routeDefinitionDTO.setOrder(order);
            return routeDefinitionDTO;
        }
    }
}
